class WorkItemsController < ApplicationController

  def index
    @stage = Stage.find(params[:stage_id])
    @type = WorkItemType.find(params[:work_item_type_id])
  end

  def new
    @stage = Stage.find(params[:stage_id])
    @type = WorkItemType.find(params[:work_item_type_id])
    @work_item = WorkItem.new(
      :stage_id => @stage.id,
      :work_item_type_id => @type.id
    )
  end

  def create
    @work_item  = WorkItem.new(params[:work_item])
    render :new unless @work_item.save
  end

  def edit
    @work_item = WorkItem.find(params[:id])
  end

  def update
    @work_item = WorkItem.find(params[:id])
    render :edit unless @work_item.update_attributes(params[:work_item])
  end

  def destroy
    @work_item = WorkItem.find(params[:id])
    @work_item.destroy
  end

end
